<template>
  <div class="app-container">
    <!--    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="68px">-->
    <!--      <el-form-item label="意见名称" prop="adviceContent">-->
    <!--        <el-input v-model="queryParams.adviceContent" placeholder="请输入意见名称" clearable-->
    <!--                  @keyup.enter.native="handleQuery"/>-->
    <!--      </el-form-item>-->
    <!--      <el-form-item>-->
    <!--        <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>-->
    <!--        <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>-->
    <!--      </el-form-item>-->
    <!--    </el-form>-->

    <el-table v-loading="loading" :data="adviceList">
      <el-table-column label="序号" align="center" prop="feedBackId" width="100">
        <template v-slot="scope">
          {{ scope.$index + 1 }}
        </template>
      </el-table-column>
      <el-table-column label="意见内容" align="center" prop="content" :show-overflow-tooltip="true"/>
      <el-table-column label="意见人" align="center" prop="nickName" :show-overflow-tooltip="true"/>
      <el-table-column label="联系方式" align="center" prop="phoneNumber" :show-overflow-tooltip="true"/>
      <el-table-column label="状态" key="status" align="center">
        <template v-slot="scope">
          {{ scope.row.status === '0' ? '待处理' : '已处理' }}
        </template>
      </el-table-column>
      <el-table-column label="创建时间" align="center" prop="createTime">
        <template v-slot="scope">
          <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d} {h}:{m}:{s}') }}</span>

        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template v-slot="scope">
          <el-button v-if="scope.row.status==0" size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
          >处理
          </el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination v-show="total>0" :total="total" :page.sync="queryParams.page" :limit.sync="queryParams.num"
                @pagination="getList"/>

  </div>
</template>

<script>
import {getFeedBackList, editFeedBack} from "@/api/advice/index";
import Editor from '@/components/Editor';


export default {
  name: "SystemNotice",
  components: {
    Editor
  },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 总条数
      total: 0,
      // 意见表格数据
      adviceList: [],
      // 查询参数
      queryParams: {
        page: 1,
        num: 10,
      },
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询意见列表 */
    getList() {
      this.loading = true;
      getFeedBackList(this.queryParams).then(response => {
        this.adviceList = response.data;
        this.total = response.total || 0
        this.loading = false;
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.page = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.$modal.confirm('是否确认将该意见标记为已处理?').then(() => {
        editFeedBack({feedBackId: row.feedBackId}).then(() => {
          this.getList();
          this.$modal.msgSuccess("操作成功")
        });
      });
    },

  }
};
</script>
